package com.voole.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.voole.dao.BaseDao;
import com.voole.dao.SysActionDao;
import com.voole.dao.SysAuthorityDao;
import com.voole.entity.SysAction;
import com.voole.entity.SysAuthority;
import com.voole.service.ISysActionService;
import com.voole.service.ISysAuthorityService;

@Service
public class SysActionServiceImpl implements ISysActionService {

	@Autowired
	BaseDao baseDao;
	@Autowired
	SysActionDao sysActionDao;
	
	/**
	 * 获取所有功能（页面访问地址）
	 */
	public List<SysAction> getList() throws Exception {
		return null;
	}

	/**
	 * 根据 fatherId（三级菜单、左侧次要目录）
	 * 获取所有功能（页面访问地址）
	 */
	public List<SysAction> getListByResourceId(Integer resourceId) throws Exception {
		return sysActionDao.getListByResourceId(resourceId);
	}
	
	/**
	 * 删除功能
	 */
	public Integer delSysAction(Integer actionId) throws Exception {
		return sysActionDao.delSysAction(actionId);
	}

	/**
	 * 删除功能（属于同一个三级目录菜单id）
	 */
	public Integer delListByResourceId(Integer resourceId) throws Exception {
		return sysActionDao.delListByResourceId(resourceId);
	}

	/**
	 * 新增四级菜单
	 * @return id
	 */
	public Integer addAction(String actionName, Integer resourceId, String url, Integer isButton, String code, String note, Integer sort, Integer status) throws Exception {
		SysAction sa = new SysAction();
		sa.setActionname(actionName);
		sa.setResourceid(resourceId);
		sa.setUrl(url);
		sa.setIsbutton(isButton);
		sa.setSort(sort);
		sa.setStatus(status);
		sa.setCode(code);
		sa.setNote(note);
		sysActionDao.addSysAction(sa);
		return sa.getId();
	}

	
	

}
